<?php

namespace App\Console\Commands\Shop;

use App\Kuafu\Shop\Model\Shop;
use App\Kuafu\Shop\Model\ShopArchives;
use Illuminate\Console\Command;

class InitShopArchives extends Command
{
    protected $signature = 'shop:initShopArchives';

    protected $description = '门店附加信息无数据时新增记录';


    public function handle()
    {

        Shop::query()
            ->with('shopArchivesRel')
            ->chunkById(100, function ($item) {
                foreach ($item as $v) {
                    $shopArchivesId = $v->shopArchivesRel->id ?? 0;
                    if (!$shopArchivesId) {
                        ShopArchives::query()->updateOrCreate(['shopId' => $v->id], ['cameraStatus' => 0]);

                        dump($v->shopCode . ' ' . $v->name);
                    }
                }
            });
    }

}
